#include "UserExample.h"

QString COLUMN_NAME_USERINT = "userInt";
QString COLUMN_NAME_USERBOOL = "userBool";
QString COLUMN_NAME_USERSTRING = "userString";
QString COLUMN_NAME_USERFLOAT = "userFloat";
QString COLUMN_NAME_USERCHAR = "userChar";

QString COLUMN_TYPE_USERINT = "int";
QString COLUMN_TYPE_USERBOOL = "bool";
QString COLUMN_TYPE_USERSTRING = "string";
QString COLUMN_TYPE_USERFLOAT = "float";
QString COLUMN_TYPE_USERCHAR = "char";

UserExampleBear::UserExampleBear()
{
    m_object = new BBObject;
    m_object->setName( "UserExample" );
    m_object->setAttributeType( COLUMN_NAME_USERINT, COLUMN_TYPE_USERINT );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_USERINT, NULL );
    m_object->setAttributeType( COLUMN_NAME_USERBOOL, COLUMN_TYPE_USERBOOL );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_USERBOOL, NULL );
    m_object->setAttributeType( COLUMN_NAME_USERSTRING, COLUMN_TYPE_USERSTRING );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_USERSTRING, NULL );
    m_object->setAttributeType( COLUMN_NAME_USERFLOAT, COLUMN_TYPE_USERFLOAT );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_USERFLOAT, NULL );
    m_object->setAttributeType( COLUMN_NAME_USERCHAR, COLUMN_TYPE_USERCHAR );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_USERCHAR, NULL );
    addObject( m_object );
}

int UserExampleBear::getUserInt()
{
    return m_object->getAttributePrimitiveValue( COLUMN_NAME_USERINT ).toInt();
}

void UserExampleBear::setUserInt( int value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_USERINT, value );
}

bool UserExampleBear::getUserBool()
{
    return m_object->getAttributePrimitiveValue( COLUMN_NAME_USERBOOL ).toBool();
}

void UserExampleBear::setUserBool( bool value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_USERBOOL, value );
}

std::string UserExampleBear::getUserString()
{
    return m_object->getAttributePrimitiveValue( COLUMN_NAME_USERSTRING ).toString().toStdString();
}

void UserExampleBear::setUserString( std::string value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_USERSTRING, QString::fromStdString( value ) );
}

float UserExampleBear::getUserFloat()
{
    return m_object->getAttributePrimitiveValue( COLUMN_NAME_USERFLOAT ).toFloat();
}

void UserExampleBear::setUserFloat( float value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_USERFLOAT, value );
}

char UserExampleBear::getUserChar()
{
    QString character = m_object->getAttributePrimitiveValue( COLUMN_NAME_USERCHAR ).toString();
    return character[0].toAscii();
}

void UserExampleBear::setUserChar( char value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_USERCHAR, QString( value ) );
}

